/*
	Copyright (C) 2013 Pontificia Universidad Catolica del Peru
	contact: http://avatar.inf.pucp.edu.pe/realidad-aumentada/
	address contact: Av. Universitaria 1801, San Miguel, Lima-Peru.
	
	This file is part of UbicAR PUCP.

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with This program.  If not, see <http://www.gnu.org/licenses/>.
*/
/*
	Authors: Alvaro Roger Agüero Sánchez, Rodolfo Javier Galvez Meza
	Pontificia Universidad Catolica del Peru
	Departamento de Ingeniería
*/

package org.grupoavatar.guiaubicua.punto;

import java.util.ArrayList;

import org.grupoavatar.guiaubicua.R;
import org.grupoavatar.guiaubicua.auxiliares.Servicio;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ServicioAdapter extends ArrayAdapter<Servicio> {

	private final Context context;
	private final ArrayList<Servicio> values;
	
	public ServicioAdapter(Context context, ArrayList<Servicio> values) {
		super(context, R.layout.servicio_item, values);
		this.context = context;
		this.values = values;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		
		View rowView = inflater.inflate(R.layout.servicio_item, parent, false);
		
		TextView txtNombre = (TextView) rowView.findViewById(R.id.txtNombreServicio);
		TextView txtDetalle = (TextView) rowView.findViewById(R.id.txtDetalleServicio);
		ImageView imgLogo = (ImageView) rowView.findViewById(R.id.imgServicio);
		
		Servicio servicio = values.get(position);
		
		txtNombre.setText(servicio.getNombre());
		txtDetalle.setText(servicio.getDetalle());
		imgLogo.setImageResource(servicio.getIcono());

		return rowView;
	}
	
}
